﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using Dapper.Contrib.Extensions;
using DapperExtensions.Mapper;

namespace MaximServices.Model
{
    public class ViewHistory
    {
        public string Id { get; set; }

        public string User_Id { get; set; }

        public string Motto_Id { get; set; }

        public DateTime? View_Date { get; set; }

        public string Source_Id { get; set; }

        public DateTime Create_Time { get; set; }

        public DateTime Modify_Time { get; set; }
    }

    public class ViewHistoryMapper : ClassMapper<ViewHistory>
    {
        public ViewHistoryMapper()
        {
            //use different table name
            Table("view_history");

            //use a custom schema
            Schema("");

            //have a custom primary key
            Map(x => x.Id).Column("id").Key(KeyType.Assigned);

            Map(x => x.User_Id).Column("user_id");
            Map(x => x.Motto_Id).Column("motto_id");
            Map(x => x.View_Date).Column("view_date");
            Map(x => x.Source_Id).Column("source_id");
            Map(x => x.Create_Time).Column("create_time");
            Map(x => x.Modify_Time).Column("modify_time");

            //optional, map all other columns
        }
    }
}
